﻿using System;
using System.Collections.Generic;
using EnvDTE;
using EnvDTE80;


namespace VsTortoiseSVN.Commands
{
    public class OpenModifiedFile : CommandBase
    {
        private Dialogs.OpenModifiedDocumentDialog _dialog { get; set; }

        public OpenModifiedFile(DTE2 application, string name, string caption, string tooltip, int bitmapId, Dialogs.OpenModifiedDocumentDialog dialogInstance)
            : base(application, name, caption, tooltip, bitmapId)
        {
            PreferredBinding = "Global::Ctrl+Shift+Alt+O";

            _dialog = dialogInstance;
        }

        public override vsCommandStatus QueryStatus()
        {
            if (!Application.HasProject())
                return vsCommandStatus.vsCommandStatusSupported;

            return vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled;
        }

        public override bool Exec()
        {
            if (!Application.SaveDocuments())
                return false;

            List<string> directoryNames = new List<string>();
            Application.Solution.GetDirectoryNames(directoryNames);
            _dialog.ShowDialog(directoryNames);
            return true;
        }
    }
}
